

*use "~/Dropbox/Satisfaction-Gender/Data Analysis/Analysis Data/Winners_Losers_Analysis_ES.dta"
*Change to your own working directory



*******************
** Hypothesis 1 votedEXEC models
******************

*votedEXEC model with full dataset
meologit Satisfaction i.votedEXEC##i.Female Education Age Income Polity_score GDP_capita_logged || Country_year:
estimates store hyp1_votedEXEC



*predictions for top plot in Figure 1 
margins, at(votedEXEC=(0(1)1) Female = (0(1)1)) vsquish post coeflegend
estimates store hyp1_votedEXEC_errors

*Differences in satisfaction boosts for bottom plot in Figure 1

*estimates restore hyp1_votedEXEC

margins r.votedEXEC, over(r.Female)



*Calculating differences for intext description 
*estimates restore hyp1_votedEXEC

margins,  at(votedEXEC = (0 1) Female = (0 1))  predict(outcome(4)) post coeflegend
estimates store hyp1_votedEXEC_4




*Test whether winner-loser gaps are significantly bigger for men than women, calculating differences "by hand" 
test (_b[1bn._at]- _b[3._at]) = (_b[2._at] -_b[4._at])

*Test whether winner-loser gaps are significantly bigger for men than women, using dydx to calculate differences

*estimates restore hyp1_votedEXEC_probs

margins, dydx(votedEXEC) at(Female = (0 1))  predict(outcome(4)) post coeflegend


test  _b[1.votedEXEC:1bn._at] =  _b[1.votedEXEC:2._at]





***********************
***********************

*******************
** Hypothesis 1 votedGOV models
******************

*votedGOV model with full dataset
 meologit Satisfaction i.votedGOV##i.Female Education Age Income Polity_score GDP_capita_logged || Country_year:
estimates store hyp1_votedGOV

*predictions for top plot in Figure A.1 
margins, at(votedGOV=(0(1)1) Female = (0(1)1)) vsquish 
estimates store hyp1_votedGOV_errors



*Differences in satisfaction boosts for bottom plot in A.1
*estimates restore hyp1_votedGOV

margins r.votedGOV, over(r.Female)


*******************
** Hypothesis 2 Descriptive models
******************




 meologit Satisfaction c.Legis_women##i.votedEXEC##i.Female Education Age Income Polity_score GDP_capita_logged i.Quota || Country_year:votedEXEC Female
estimates store hyp2_votedEXEC_legis


*predictions for top plot in Figure 2

margins, at(Legis_women = (5(5)40) votedEXEC=(0(1)1) Female = (0(1)1)) vsquish 
estimates store hyp2exec_legis


*Differences in satisfaction boosts for bottom plot in Figure 2

*estimates restore hyp2_votedEXEC_legis

margins r.votedEXEC, over(r.Female) at(Legis_women = (5(5)40))  



 meologit Satisfaction c.Legis_women##i.votedGOV##i.Female Education Age Income Polity_score GDP_capita_logged i.Quota|| Country_year:votedGOV Female
estimates store hyp2_votedGOV_legis


*predictions for top plot in Figure A.2
margins, at(Legis_women = (5(5)40) votedGOV=(0(1)1) Female = (0(1)1)) vsquish 
estimates store hyp2gov_legis

*Differences in satisfaction boosts for bottom plot in Figure A.2
*estimates restore hyp2_votedGOV_legis

margins r.votedGOV, over(r.Female) at(Legis_women = (5(5)40))  


*******************
** Hypothesis 2 HOG models
******************

 meologit Satisfaction i.HOG_combine##i.votedEXEC##i.Female Education Age Income Polity_score GDP_capita_logged i.Quota || Country_year:votedEXEC Female
estimates store hyp2_votedEXEC_HOG



*predictions for top plot in Figure 3

margins, at(HOG_combine = (0(1)1) votedEXEC=(0(1)1) Female = (0(1)1)) vsquish 
estimates store hyp2exec_HOG


*Differences in satisfaction boosts for bottom plot in Figure 3
*estimates restore hyp2_votedEXEC_HOG

margins r.votedEXEC, over(r.Female) at(HOG_combine = (0(1)1))  




 meologit Satisfaction i.HOG_combine##i.votedGOV##i.Female Education Age Income Polity_score GDP_capita_logged i.Quota || Country_year:votedGOV Female
estimates store hyp2_votedGOV_HOG


*predictions for top plot in A.3

margins, at(HOG_combine = (0(1)1) votedGOV=(0(1)1) Female = (0(1)1)) vsquish 




*Differences in satisfaction boosts for bottom plot in Figure A.3
*estimates restore hyp2_votedGOV_HOG

margins r.votedGOV, over(r.Female) at(HOG_combine = (0(1)1))  



**** Make table outputs for models
*Note that tables were edited in latex to appear as they do in Appendix


*** Command to make Table A.2
 
esttab hyp1_votedEXEC hyp2_votedEXEC_legis hyp2_votedEXEC_HOG using Table_A2.tex, b(3) se(3)  nostar aic scalars(chi2)


*** Command to make Table A.3


esttab hyp1_votedGOV hyp2_votedGOV_legis hyp2_votedGOV_HOG using Table_A3.tex, b(3) se(3)  nostar aic scalars(chi2)
